<?php
class Form_AdminLogin extends Zend_Form
{
    public function init()
    {
        $this->setAction('/')
              ->setAttrib('id', 'AdminLoginForm')
             ->setMethod('post')
             ->addElementPrefixPaths(array(
                  'validate' => array('prefix' => 'WE_Validator', 'path' => 'WE/Validator/'),
               ));
             
        $this->addElement('text', 'username', array(
            'label' => '管理员',
            'validators' => array(
                array('StringLength', true, array(4, 60, 'messages' => array(
                        Zend_Validate_StringLength::TOO_SHORT => '管理员名至少需要 %min% 字',
                        Zend_Validate_StringLength::TOO_LONG => '管理员名不得超过 %max% 字',
                    ),)),
            	'AdminLoginPasswordOk',
            		
                
            ),
            'required' => true,
            'filters' => array(
                'StringToLower', 
                'StringTrim'
            ),
            'decorators' => array(
                'ViewHelper',
                'Errors',
                'Label',
                array('HtmlTag', array('tag' => 'div', 'class' => 'formLogin')),                
            )
        ));
        
        $this->addElement('password', 'password', array(
            'label' => '密码',
            'validators' => array(
                array('StringLength', false, array(
                    6,
                    15,
                    'messages' => array(
                        Zend_Validate_StringLength::TOO_SHORT => '密码至少需要 %min% 字',
                        Zend_Validate_StringLength::TOO_LONG => '密码不得超过 %max% 字',
                    ),
                	'encoding'=>'UTF-8',
                )),            	
            ),
        	//
            'required' => true,
            'filters' => array(
                'StringToLower',
                'StringTrim',
            ),
            'decorators' => array(
                'ViewHelper',
                'Errors',
                'Label',
                array('HtmlTag', array('tag' => 'div', 'class' => 'formPassword')),                
            )
        ));
        
        //rememberMe
        $this->addElement('checkbox', 'remember_me', array(
            'label' => '下次自动登陆',
            'validators' => array(
                array('InArray', false, array(
                    array('1', '0'),
                    'messages' => array('notInArray' => 'Erreur Dans la requette'),
                )),
            ),
        ));
        
           
        
        $this->addElement('submit', 'submit',array('label'=>'登陆'));
        
        $this->addElement('hidden', 'cible', array(
            'value' => 'login',
			      
        ));
    }
}
